package com.xiang.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiang.doman.Good;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface GoodMapper extends BaseMapper<Good> {

//try阶段  预留资源
    @Update(" update t_good set good_stock = good_stock - #{num},good_induce= good_induce+ #{num} where id = #{goodId}")
    void reduceStock(@Param("goodId") int goodId,@Param("num") int num);

    //commit阶段
    @Update("update t_good set good_induce= good_induce - #{num} where id = #{goodId}")
    void commitStock(@Param("goodId") int goodId,@Param("num") int num);

    //cancle阶段
    @Update(" update t_good set good_stock = good_stock + #{num},good_induce= good_induce - #{num} where id = #{goodId}")
    void cancleStock(@Param("goodId") int goodId,@Param("num") int num);
}
